# -*- coding: utf-8 -*-#

# -------------------------------------------------------------------------------
# Name:         redis_utils
# Description:  
# Author:       zhuchunxu
# Date:         2020/11/3
# -------------------------------------------------------------------------------
import redis

from spider_source.config import REDIS_SERVER_HOST, REDIS_PASS


class RedisUtils:
    def __init__(self):
        # 连接池
        pool = redis.ConnectionPool(host=REDIS_SERVER_HOST, port=6379,
                                    password=REDIS_PASS, max_connections=1024,
                                    decode_responses=True
                                    )
        self.conn = redis.Redis(connection_pool=pool)

    def insert(self, key, *args):
        for i in args:
            self.conn.lpush(key, i)
